package com.osmino.contacts.view.base;

import android.app.Activity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.osmino.contacts.R;
import com.osmino.contacts.view.IStyleableView;
import com.osmino.contacts.view.style.Style;

public class Tab extends RelativeLayout implements IStyleableView, OnClickListener{
	
	public static final int LAYOUT = R.layout.tab;
	
	public static final int ROOT_RL = R.id.tab_bg_rl;
	public static final int IV = R.id.tab_iv;
	public static final int TEXT = R.id.tab_text_tv;
	
	private RelativeLayout root;
	private TabClient client;
	
	public Tab(Activity activity, TabClient client) {
		super(activity);
		root = (RelativeLayout) activity.getLayoutInflater().inflate(LAYOUT, this);
		this.client = client;
		setOnClickListener(this);
	}

	@Override
	public void setStyle(Style style) {
	}
	
	public void setText(String text){
		TextView tv = (TextView) findViewById(TEXT);
		tv.setText(text);
	}
	
	public void setPic(int resource){
		ImageView iv = (ImageView) findViewById(IV);
		iv.setImageResource(resource);
	}
	
	public interface TabClient{
		public void onTabClick(View v);
	}

	@Override
	public void onClick(View v) {
		client.onTabClick(v);
	}
}